home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / net3d-0.08 / brain.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  4KB  |  104 lines

  1. /* brain.h
  2.  *
  3.  * Structures and constants for a vehicle brain state machine
  4.  */
  5. #ifndef brain_h
  6. #define brain_h
  7.  
  8. struct link;        /* forward definition */
  9.  
  10. struct state {
  11.     int num;        /* state number */
  12.     long action;        /* what happens when state is entered */
  13.     int lcount;        /* number of links from state */
  14.     struct link *links;    /* array of links */
  15.     };
  16. /* Information about one state in a brain state machine. */
  17.  
  18. struct link {
  19.     long cond;        /* t/f conditions for taking this link */
  20.     long mask;        /* conditions link depend on */
  21.     int st;
  22.     };
  23. /* A link from one state to the next */
  24.  
  25. #ifdef alternate_conditions
  26. /* Condition codes.
  27.  * The target is the last vehicle chosen by the 'newtarget' action.
  28.  */
  29. #define c_always    1<<0        /* always jump */
  30. #define c_obleft    1<<1        /* object just to left */
  31. #define c_obright    1<<2        /* object just to right */
  32. #define c_obabove    1<<3        /* object just above */
  33. #define c_obbelow    1<<4        /* object just below */
  34. #define c_tarleft    1<<5        /* target to left */
  35. #define c_tarright    1<<6        /* target to right */
  36. #define c_tarabove    1<<7        /* target at higher altitude */
  37. #define c_tarbelow    1<<8        /* target at lower altitude */
  38. #define c_forward    1<<9        /* moving forward */
  39. #define c_backward    1<<10        /* moving backwards */
  40. #define c_tarahead    1<<11        /* target directly ahead */
  41. #define c_threatahead    1<<12        /* threat ahead */
  42. #define c_sceneryahead    1<<13        /* scenery/building ahead */
  43. #define c_treeahead    1<<14        /* tree ahead */
  44. #define c_underfire    1<<15        /* hit in the last second */
  45.  
  46. /* Action codes 
  47.  */
  48. #define a_left        (1<<0)        /* accellerate left */
  49. #define a_right        (1<<1)        /* accelleration right */
  50. #define a_climb        (1<<2)        /* accel upwards */
  51. #define a_dive        (1<<3)        /* accel downwards */
  52. #define a_accel        (1<<4)        /* accellarate */
  53. #define a_decel        (1<<5)        /* decellarate */
  54. #define a_fire        (1<<6)        /* fire one shot */
  55. #define a_newtarget    (1<<7)        /* lock onto object ahead */
  56. #define a_stop        (1<<8)        /* halt all movement */
  57. #define a_threattarget    (1<<9)        /* lock onto last attacker */
  58. #endif /* alternate conditions */
  59.  
  60. /* Conditions that a link depends on 
  61.  */
  62. #define c_hplow        (1<<0)        /* hp below 5 */
  63. #define c_ammolow    (1<<1)        /* ammo below 5 */
  64. #define c_threatfar    (1<<2)        /* threat far ahead */
  65. #define c_treefar    (1<<3)        /* tree far ahead */
  66. #define c_anyfar    (1<<4)        /* something far ahead */
  67. #define c_threatclose    (1<<5)        /* threat close ahead */
  68. #define c_treeclose    (1<<6)        /* tree close ahead */
  69. #define c_anyclose    (1<<7)        /* something close ahead */
  70. #define c_underfire    (1<<8)        /* been hit in last second */
  71. #define c_reload    (1<<9)        /* currently reloading */
  72. #define c_reslow    (1<<10)        /* resources below 5 */
  73. #define c_moving    (1<<11)        /* moving forward/back */
  74. #define c_stall        (1<<12)        /* below stall speed */
  75. #define c_altlow    (1<<13)        /* altitude below 10 */
  76. #define c_above        (1<<14)        /* thing ahead is at higher alt */
  77. #define c_below        (1<<15)        /* thing ahead is at lower alt */
  78. #define c_always    (1<<16)        /* always take this branch */
  79. #define c_prizefar    (1<<17)        /* ammo/weapon bonus ahead */
  80. #define c_prizeclose    (1<<18)        /* ammo/weapon bonus close ahead */
  81. #define c_random    (1<<19)        /* 50% likely to be true */
  82. #define c_counting    (1<<20)        /* frame count still > 0 */
  83. #define c_collision    (1<<21)        /* just bumped into something */
  84. #define CONDITIONCOUNT    22
  85.  
  86. /* actions taken when a state is entered */
  87. #define a_noop        (1<<0)        /* do nothing */
  88. #define a_shoot        (1<<1)        /* fire at thing ahead */
  89. #define a_stop        (1<<2)        /* stop all motion */
  90. #define a_accel        (1<<3)        /* speed up */
  91. #define a_decel        (1<<4)        /* slow down */
  92. #define a_left        (1<<5)        /* rotate left */
  93. #define a_right        (1<<6)        /* rotate right */
  94. #define a_climb        (1<<7)        /* climb up */
  95. #define a_dive        (1<<8)        /* dive down */
  96. #define a_detonate    (1<<9)        /* self destruct */
  97. #define a_wall        (1<<10)        /* build a wall */
  98. #define a_mine        (1<<11)        /* lay a mine */
  99. #define a_gunsite    (1<<12)        /* build a gunsite */
  100. #define a_starttimer    (1<<13)        /* add 5 seconds to timer */
  101. #define ACTIONCOUNT    14
  102.  
  103. #endif /* brain_h */
  104.